﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using ReplayViewer;
using System.Reflection;
using System.Threading;
namespace ServerYuGi
{
    public class XSocketReciveEventArgs : EventArgs
    {
        public byte[] Data { get; private set; }
        public YUser user { get; private set; }
        public XSocketReciveEventArgs(byte[] data, YUser user)
        {
            this.Data = data;
            this.user = user;
        }
    }

    public class YUser
    {
        public int ID;
       
        int idx = 0;
        public YUser(int id)
        {
            this.ID = id;
          
        }

        // Tin:
        // all Face Message  Recive Write Here
        public void AddQueueDataSend(YMSG message, params object[] param)
        {
            Type t = typeof(YUser);
            MethodInfo handler = t.GetMethod("Fake_Process_" + message.ToString(), BindingFlags.NonPublic | BindingFlags.Instance);
            if (handler == null)
            {
                //Console.WriteLine("----Player  {0} Skip Message: {1}", ID, message);
            }
            else
                handler.Invoke(this, new object[] { message, param });
           
        }

        internal void SendFakeMessage(YMSG message, params object[] param)
        {
            Console.WriteLine("-----------------------------------Player  {0} Send Fake Message: {1}", ID, message);
            Thread.Sleep(300);
            Program.sup.SendMessageToServer(message, param);
            
        }

        private void Fake_Process_GAME_CHIABAI(YMSG message, params object[] param)
        {
            if (!Program.time_line.IsRun)
                Program.time_line.Start();
          
        }



    }
}
